package com.xinbochuang.machine.admin.domain.macRoom;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Data
@EqualsAndHashCode(callSuper = false)
@TableName("MAC_INDUSTRIAL")
public class MacIndustrial implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId("id")
    private String id;

    /**
     * 机房名称
     */
    @TableField("name")
    private String name;

    /**
     * 机房名称
     */
    @TableField("regionid")
    private String regionid;

    @TableField("state")
    private String state;

    @TableField("createtime")
    private Date createtime;

    @TableField("addr")
    private String addr;


    /**
     * 请求参数
     */
    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Map<String, Object> params;
    /**
     * 分页页码
     */
    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer pageNum;

    /**
     * 分页条数
     */
    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer pageSize;

    /**
     * 分页起始条数
     */
    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer begin;


    /**
     * 分页结束条数
     */
    @TableField(exist = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer end;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }

    /**
     * 初始化分页参数
     */
    public void initPage() {
        this.begin = (this.pageNum - 1) * this.pageSize;
        this.end = this.pageNum * this.pageSize;
    }
}
